package com.qys.livesMall.shop.modal.vo;

import cn.hutool.core.date.LocalDateTimeUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

@Data
public class ShopWithdrawalsStatisticsVO {
    private String id;

    @Schema(description = "用户Id")
    private Long userId;


    @Schema(description = "店铺ID")
    private Long shopId;

    @Schema(description = "店铺UID")
    private String shopCode;

    @Schema(description = "店铺名称")
    private String shopName;

    @Schema(description = "代理名称")
    private String agentAccount;

    @Schema(description = "会员层级")
    private String storey;

    @Schema(description = "提现金额")
    private BigDecimal amount;

    @Schema(description = "提现前金额")
    private BigDecimal amountBeforeChange;

    @Schema(description = "提现通道ID")
    private Integer channelId;

    @Schema(description = "提现通道")
    private String withdrawalChannel;

    @Schema(description = "直推人数")
    private Integer directNumber;

    @Schema(description = "3代人数")
    private Integer lastThreeNum;

    @Schema(description = "伞下人数")
    private Integer teamNum;//todo

    @Schema(description = "30天过期数")
    private Integer expireRecent;

    @Schema(description = "30天新增")
    private Integer recentAdd;

    @Schema(description = "3代充提差")
    private BigDecimal lastThreeDifference;

    @Schema(description = "团队充提差")
    private BigDecimal teamDifference;//todo

    @Schema(description = "团队待审核")
    private BigDecimal teamWaitWithdrawal;//todo

    @Schema(description = "3代复充")
    private BigDecimal lastThreeGenRecharge;

    @Schema(description = "3代提现")
    private BigDecimal lastThreeWithdrawal;

    @Schema(description = "团队复充")
    private BigDecimal teamRepeatedRecharge;

    @Schema(description = "团队提现")
    private BigDecimal teamWithdrawal;

    @Schema(description = "3代过期数")
    private Integer expireNumber;
    @Schema(description = "团队过期数")
    private Integer teamExpireNumber;//todo

    @Schema(description = "首冲时间")
    private LocalDateTime firstCharge;

    @Schema(description = "首冲天数")
    private Integer firstChargeDay;

    @Schema(description = "提现次数")
    private Integer withdrawalNumber;

    @Schema(description = "注册IP")
    private String applyIp;

    @Schema(description = "同注册IP数")
    private Integer sameRegisterIpNum;

    @Schema(description = "充值差额")
    private BigDecimal difference;

    @Schema(description = "申请时间")
    private LocalDateTime createDate;

    @Schema(description = "审核时间")
    private LocalDateTime auditDate;

    @Schema(description = "审核状态")
    private Integer status;

    @Schema(description = "发放状态")
    private Integer grantStatus;//todo

    @Schema(description = "发放时间")
    private LocalDateTime grantDate;//todo


    @Schema(description = "上级账号")
    private String superiorName;

    @Schema(description = "操作人")
    private String auditUserName;

    @Schema(description = "订单号")
    private String orderNo;

    @Schema(description = "资料备注")
    private String profileRemake;
    @Schema(description = "提现备注")
    private String description;
    @Schema(description = "审核备注")
    private String auditDesc;


    @Schema(description = "提现地址")
    private String accountNumber;

    @Schema(description = "到账金额")
    private BigDecimal actualArrivalAmount;

    @Schema(description = "回调金额")
    private BigDecimal callbackAmount;

    @Schema(description = "提现方式")
    private Integer payMethod;

    @Schema(description = "提现时间(小时)")
    private Integer withdrawalTime;//todo

    private LocalDateTime createTime;

    public BigDecimal getTeamWaitWithdrawal() {
        if (teamWaitWithdrawal==null){
            return BigDecimal.ZERO;
        }
        return teamWaitWithdrawal;
    }

    public Long getFirstChargeDay() {
        if(createTime!=null&&firstCharge!=null) {
            return LocalDateTimeUtil.between(createTime, firstCharge, ChronoUnit.DAYS);
        }
        return null;
    }

    public Integer getSameRegisterIpNum() {
        if (sameRegisterIpNum==null){
            return 1;
        }
        return sameRegisterIpNum;
    }
}
